package com.teemor.im.executor;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.LinkedBlockingDeque;

/**
 * @ename zhoulk
 * @cname 周李科
 * @date 2020/6/17 14:31
 */
@Slf4j
public class CommandQueue {

    private final LinkedBlockingDeque<CommandTask> commandTasks = new LinkedBlockingDeque<>(1000);

    public CommandTask pop() {
        try {
            return commandTasks.take();
        } catch (InterruptedException e) {
            log.error("命令处理获取任务失败！", e);
            return null;
        }
    }

    public void push(CommandTask task) {
        try {
            commandTasks.put(task);
        } catch (InterruptedException e) {
            log.error("命令处理添加任务失败！", e);
        }
    }


}
